The Evolution of an Object-orietented Compiler Framework

نویسنده

  • Justin O. Graver
چکیده

class creation Abstract classes are important in the creation of any general-purpose framework. Such classes are frequently created simply by factoring out the common behavior from several related or sibling classes. However, the creation process for abstractclasses are important in the creation of any general-purpose framework. Such classes are frequently created simply by factoring out the common behavior from several related or sibling classes. However, the creation process for abstract classes is often subjective and creative, being guided by domain knowledge, experience, and intuition about what constitutes good and bad domain abstractions. While TypedParser provided some guidance for such factoring in the front-end framework, the abstract classes created were based primarily on the expected behavior of scanners and parsers. Figure 3. The old and new Smalltalk compiler class hierarchies AN OBJECT-ORIENTED COMPILER FRAMEWORK 527 A common misconception about abstract classes is that they can be anticipated and designed top-down at the beginning of a project. Unfortunately, it is often hard to derive good abstractions from the narrow focus imposed by the context of a single project. Useful abstract classes are often discovered during the post-mortem of a prototype implementation or during the implementation of a similar application, as opposed to during the initial design process. Two goals of the new front-end classes were to make the compiler easier to understand and to make it easier to create new varieties of compilers through subclassing. We examined the existing front-end classes and identified which properties were general enough to be included in the more abstract front-end framework. It was decided that two abstract classes, AbstractScanner and AbstractParser, would be sufficient. AbstractScanner, abstracted from Scanner, is an abstract class that provides protocols (related sets of messages that can be sent to instances of a class) for basic source stream manipulation, scanning support, and error handling. Scanner was renamed SmalltalkScanner and retained specific Smalltalk token scanning protocol, the required public access protocol, and more specialized error handling. AbstractParser, abstracted from SmalltalkParser, has protocols for public access, basic token acquisition, and error handling support. AbstractParser has an instance variable class to provide a class as a context for compiling. Exactly how this variable is used is determined by subclasses. Encoder, an esoteric parse node class, is used by the Smalltalk compiler as a symbol table. One of the primary functions of Smalltalk encoders is to maintain a mapping from variable names to their corresponding parse tree leaf nodes. In this manner, all occurrences of a variable within a parse tree can be represented by a single parse tree node. Historically, this technique was used to minimize the space required by the leaf nodes of a parse tree. As a prelude to future redesign and reimplementation of encoder functionality, we chose to represent the ‘encoder concept’ abstractly in the AbstractParser class, as opposed to being hard-coded into the parser. A particular class of encoder may be either created and initialized, by overriding the method stub initEncoder in a concrete subclass, or passed in as an argument with the source code.Parser, abstracted from SmalltalkParser, has protocols for public access, basic token acquisition, and error handling support. AbstractParser has an instance variable class to provide a class as a context for compiling. Exactly how this variable is used is determined by subclasses. Encoder, an esoteric parse node class, is used by the Smalltalk compiler as a symbol table. One of the primary functions of Smalltalk encoders is to maintain a mapping from variable names to their corresponding parse tree leaf nodes. In this manner, all occurrences of a variable within a parse tree can be represented by a single parse tree node. Historically, this technique was used to minimize the space required by the leaf nodes of a parse tree. As a prelude to future redesign and reimplementation of encoder functionality, we chose to represent the ‘encoder concept’ abstractly in the AbstractParser class, as opposed to being hard-coded into the parser. A particular class of encoder may be either created and initialized, by overriding the method stub initEncoder in a concrete subclass, or passed in as an argument with the source code. SmalltalkParser, a concrete subclass of AbstractParser, provides Smalltalk-specific parsing expressions, specialized error handling facilities, and miscellaneous public access protocols as required by the rest of the system. This functionality was formerly implemented in Compiler. Responsibility migration An instance of class Compiler accepts as input either a string or a ReadStream. The input is tested and converted into a ReadStream, if necessary, before passing it to the scanner/parser. This function was delegated to AbstractScanner, making scanners completely responsible for handling the input source. This refactoring involves the movement of methods from one class to another. It may also be characterized as the migration of a responsibility from one class to another. 7 AbstractParser has an instance variable scanner to access its associated scanner. In this case, the responsibility has migrated from an object into one of its components. Scanner had another subclass, ChangeScanner, which also had to be reimplemented. ChangeScanner, now a subclass of SmalltalkScanner, is used to convert

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Multi-Formalism Modeling Framework: Formal Definitions, Model Composition and Solution Strategies

In this paper, we present a multi-formalism modeling framework (abbreviated by MFMF) for modeling and simulation. The proposed framework is defined based on the concepts of meta-models and uses object-orientation to overcome the complexities and to enhance the extensibility. The framework can be used as a basis for modeling by various formalisms and to support model composition in a unified man...

متن کامل

A Multi-Formalism Modeling Framework: Formal Definitions, Model Composition and Solution Strategies

In this paper, we present a multi-formalism modeling framework (abbreviated by MFMF) for modeling and simulation. The proposed framework is defined based on the concepts of meta-models and uses object-orientation to overcome the complexities and to enhance the extensibility. The framework can be used as a basis for modeling by various formalisms and to support model composition in a unified man...

متن کامل

A Useful Family of Stochastic Processes for Modeling Shape Diffusions

 One of the new area of research emerging in the field of statistics is the shape analysis. Shape is defined as all the geometrical information of an object whose location, scale and orientation is not of interest. Diffusion in shape analysis can be studied via either perturbation of the key coordinates identifying the initial object or random evolution of the shape itself. Reviewing the f...

متن کامل

Object-Based Classification of UltraCamD Imagery for Identification of Tree Species in the Mixed Planted Forest

This study is a contribution to assess the high resolution digital aerial imagery for semi-automatic analysis of tree species identification. To maximize the benefit of such data, the object-based classification was conducted in a mixed forest plantation. Two subsets of an UltraCam D image were geometrically corrected using aero-triangulation method. Some appropriate transformations were perfor...

متن کامل

Application of Combined Local Object Based Features and Cluster Fusion for the Behaviors Recognition and Detection of Abnormal Behaviors

In this paper, we propose a novel framework for behaviors recognition and detection of certain types of abnormal behaviors, capable of achieving high detection rates on a variety of real-life scenes. The new proposed approach here is a combination of the location based methods and the object based ones. First, a novel approach is formulated to use optical flow and binary motion video as the loc...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Softw., Pract. Exper.

دوره 22  شماره 

صفحات  -

تاریخ انتشار 1992